using System;
using System.Data;
using System.Collections.Generic;
using ADOBase;
namespace eTMS.DAO{
	/********************************BEGIN KhachHangDAO****************************************/
	///<summary>
	/// <para>Author: Auto generated class by CSharp Code Generator v2.0</para>
	/// <para>Date:27/10/2011 56:03:12</para>
	/// <para>Class Name: KhachHangDAO</para>
	/// <para>Description: Class access to table KhachHang in database. Coder should'nt code here.</para>
	///</summary>

	
	public partial class KhachHangDAO : DAOBase<KhachHangEntity>{


		#region Select functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: CreateSelectOneCommand</para>
		/// <para>Input: KhachHang_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectOneCommand(int KhachHang_ID){
			string strSQL="SELECT  [KhachHang_ID],[MaKhachHang],[TenKhachHang],[NgaySinh],[GioiTinh],[DiaChi],[QuanHuyen_ID],[TinhThanh_ID],[DiDong],[CoDinh],[PhuHuynh],[ThanhPhan_ID],[TruongHoc],[CaHoc_ID],[GioHoc],[Email],[DanhGia],[GhiChu],[SinhVien_ID],[NganhHoc_ID],[TrangThai_ID],[NguonTin_ID],[NgayNhap],[NgayCapNhat],[User_ID],[KetThuc],[NgayKetThuc] FROM [KhachHang]  WHERE [KhachHang].[KhachHang_ID]=@KhachHang_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@KhachHang_ID",KhachHang_ID);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: SelectOne</para>
		/// <para>Input: KhachHang_ID</para>
		/// <para>Output: KhachHangEntity</para>
		///</summary>
		public KhachHangEntity SelectOne(int KhachHang_ID){
			IDbCommand cmd=this.CreateSelectOneCommand(KhachHang_ID);
			return this.Select(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: SelectOneByMaKhachHang</para>
		/// <para>Input: MaKhachHang</para>
		/// <para>Output: KhachHangEntity</para>
		///</summary>
		public KhachHangEntity SelectOneByMaKhachHang(string MaKhachHang){
			IDbCommand cmd=this.CreateSelectAllByKeyCommand("MaKhachHang",MaKhachHang);
			return this.Select(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: CreateSelectAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllCommand(){
			string strSQL="SELECT  [KhachHang_ID],[MaKhachHang],[TenKhachHang],[NgaySinh],[GioiTinh],[DiaChi],[QuanHuyen_ID],[TinhThanh_ID],[DiDong],[CoDinh],[PhuHuynh],[ThanhPhan_ID],[TruongHoc],[CaHoc_ID],[GioHoc],[Email],[DanhGia],[GhiChu],[SinhVien_ID],[NganhHoc_ID],[TrangThai_ID],[NguonTin_ID],[NgayNhap],[NgayCapNhat],[User_ID],[KetThuc],[NgayKetThuc] FROM [KhachHang] ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: CreateSelectAllByKeyCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyCommand(string ColumnName,object Value){
			string strSQL="SELECT  [KhachHang_ID],[MaKhachHang],[TenKhachHang],[NgaySinh],[GioiTinh],[DiaChi],[QuanHuyen_ID],[TinhThanh_ID],[DiDong],[CoDinh],[PhuHuynh],[ThanhPhan_ID],[TruongHoc],[CaHoc_ID],[GioHoc],[Email],[DanhGia],[GhiChu],[SinhVien_ID],[NganhHoc_ID],[TrangThai_ID],[NguonTin_ID],[NgayNhap],[NgayCapNhat],[User_ID],[KetThuc],[NgayKetThuc] FROM [KhachHang]  WHERE [KhachHang].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of KhachHangEntity</para>
		///</summary>
		public List<KhachHangEntity> SelectAll(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: SelectAllDS</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDS(){
			IDbCommand cmd=this.CreateSelectAllCommand();
			return this.SelectDS(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: CreateSelectAllFilterCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllFilterCommand(string strFilter){
			string strSQL="SELECT  [KhachHang_ID],[MaKhachHang],[TenKhachHang],[NgaySinh],[GioiTinh],[DiaChi],[QuanHuyen_ID],[TinhThanh_ID],[DiDong],[CoDinh],[PhuHuynh],[ThanhPhan_ID],[TruongHoc],[CaHoc_ID],[GioHoc],[Email],[DanhGia],[GhiChu],[SinhVien_ID],[NganhHoc_ID],[TrangThai_ID],[NguonTin_ID],[NgayNhap],[NgayCapNhat],[User_ID],[KetThuc],[NgayKetThuc] FROM [KhachHang]  WHERE "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: CreateSelectAllByKeyFilterCommand</para>
		/// <para>Input: ColumnName,ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateSelectAllByKeyFilterCommand(string strFilter,string ColumnName,object Value){
			string strSQL="SELECT  [KhachHang_ID],[MaKhachHang],[TenKhachHang],[NgaySinh],[GioiTinh],[DiaChi],[QuanHuyen_ID],[TinhThanh_ID],[DiDong],[CoDinh],[PhuHuynh],[ThanhPhan_ID],[TruongHoc],[CaHoc_ID],[GioHoc],[Email],[DanhGia],[GhiChu],[SinhVien_ID],[NganhHoc_ID],[TrangThai_ID],[NguonTin_ID],[NgayNhap],[NgayCapNhat],[User_ID],[KetThuc],[NgayKetThuc] FROM [KhachHang]  WHERE [KhachHang].["+ColumnName+"]=@ColumnName AND "+RemoveInjection(strFilter);
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: SelectAll</para>
		/// <para>Input: </para>
		/// <para>Output: List of KhachHangEntity</para>
		///</summary>
		public List<KhachHangEntity> SelectAllFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectList(cmd);
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: SelectAllDSFilter</para>
		/// <para>Input: </para>
		/// <para>Output: DataSet</para>
		///</summary>
		public DataSet SelectAllDSFilter(string strFilter){
			IDbCommand cmd=this.CreateSelectAllFilterCommand(strFilter);
			return this.SelectDS(cmd);
		}
		#endregion

		#region Insert functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: CreateInsertCommand</para>
		/// <para>Input: KhachHangEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateInsertCommand(KhachHangEntity o){
			string strSQL="INSERT INTO [KhachHang]([MaKhachHang],[TenKhachHang],[NgaySinh],[GioiTinh],[DiaChi],[QuanHuyen_ID],[TinhThanh_ID],[DiDong],[CoDinh],[PhuHuynh],[ThanhPhan_ID],[TruongHoc],[CaHoc_ID],[GioHoc],[Email],[DanhGia],[GhiChu],[SinhVien_ID],[NganhHoc_ID],[TrangThai_ID],[NguonTin_ID],[NgayNhap],[NgayCapNhat],[User_ID],[KetThuc],[NgayKetThuc]) VALUES  (@MaKhachHang,@TenKhachHang,@NgaySinh,@GioiTinh,@DiaChi,@QuanHuyen_ID,@TinhThanh_ID,@DiDong,@CoDinh,@PhuHuynh,@ThanhPhan_ID,@TruongHoc,@CaHoc_ID,@GioHoc,@Email,@DanhGia,@GhiChu,@SinhVien_ID,@NganhHoc_ID,@TrangThai_ID,@NguonTin_ID,@NgayNhap,@NgayCapNhat,@User_ID,@KetThuc,@NgayKetThuc);SELECT  @@IDENTITY";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullMaKhachHang)
				this.CreateCommandParameter(cmd,"@MaKhachHang",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@MaKhachHang",o.MaKhachHang);

			if(o.IsNullTenKhachHang)
				this.CreateCommandParameter(cmd,"@TenKhachHang",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TenKhachHang",o.TenKhachHang);

			if(o.IsNullNgaySinh)
				this.CreateCommandParameter(cmd,"@NgaySinh",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NgaySinh",o.NgaySinh);

			if(o.IsNullGioiTinh)
				this.CreateCommandParameter(cmd,"@GioiTinh",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GioiTinh",o.GioiTinh);

			if(o.IsNullDiaChi)
				this.CreateCommandParameter(cmd,"@DiaChi",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DiaChi",o.DiaChi);

			if(o.IsNullQuanHuyen_ID)
				this.CreateCommandParameter(cmd,"@QuanHuyen_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@QuanHuyen_ID",o.QuanHuyen_ID);

			if(o.IsNullTinhThanh_ID)
				this.CreateCommandParameter(cmd,"@TinhThanh_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TinhThanh_ID",o.TinhThanh_ID);

			if(o.IsNullDiDong)
				this.CreateCommandParameter(cmd,"@DiDong",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DiDong",o.DiDong);

			if(o.IsNullCoDinh)
				this.CreateCommandParameter(cmd,"@CoDinh",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@CoDinh",o.CoDinh);

			if(o.IsNullPhuHuynh)
				this.CreateCommandParameter(cmd,"@PhuHuynh",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PhuHuynh",o.PhuHuynh);

			if(o.IsNullThanhPhan_ID)
				this.CreateCommandParameter(cmd,"@ThanhPhan_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@ThanhPhan_ID",o.ThanhPhan_ID);

			if(o.IsNullTruongHoc)
				this.CreateCommandParameter(cmd,"@TruongHoc",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TruongHoc",o.TruongHoc);

			if(o.IsNullCaHoc_ID)
				this.CreateCommandParameter(cmd,"@CaHoc_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@CaHoc_ID",o.CaHoc_ID);

			if(o.IsNullGioHoc)
				this.CreateCommandParameter(cmd,"@GioHoc",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GioHoc",o.GioHoc);

			if(o.IsNullEmail)
				this.CreateCommandParameter(cmd,"@Email",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Email",o.Email);

			if(o.IsNullDanhGia)
				this.CreateCommandParameter(cmd,"@DanhGia",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DanhGia",o.DanhGia);

			if(o.IsNullGhiChu)
				this.CreateCommandParameter(cmd,"@GhiChu",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GhiChu",o.GhiChu);

			if(o.IsNullSinhVien_ID)
				this.CreateCommandParameter(cmd,"@SinhVien_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SinhVien_ID",o.SinhVien_ID);

			if(o.IsNullNganhHoc_ID)
				this.CreateCommandParameter(cmd,"@NganhHoc_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NganhHoc_ID",o.NganhHoc_ID);

			if(o.IsNullTrangThai_ID)
				this.CreateCommandParameter(cmd,"@TrangThai_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TrangThai_ID",o.TrangThai_ID);

			if(o.IsNullNguonTin_ID)
				this.CreateCommandParameter(cmd,"@NguonTin_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NguonTin_ID",o.NguonTin_ID);

			if(o.IsNullNgayNhap)
				this.CreateCommandParameter(cmd,"@NgayNhap",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NgayNhap",o.NgayNhap);

			if(o.IsNullNgayCapNhat)
				this.CreateCommandParameter(cmd,"@NgayCapNhat",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NgayCapNhat",o.NgayCapNhat);

			if(o.IsNullUser_ID)
				this.CreateCommandParameter(cmd,"@User_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@User_ID",o.User_ID);

			if(o.IsNullKetThuc)
				this.CreateCommandParameter(cmd,"@KetThuc",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@KetThuc",o.KetThuc);

			if(o.IsNullNgayKetThuc)
				this.CreateCommandParameter(cmd,"@NgayKetThuc",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NgayKetThuc",o.NgayKetThuc);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: Save</para>
		/// <para>Input: KhachHangEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Save(KhachHangEntity o){
			bool result=false;
			IDbCommand cmd=this.CreateInsertCommand(o);
			object id=this.ExecuteScalar(cmd,ref result);
			cmd.Dispose();
			try{
				o.KhachHang_ID=int.Parse(Convert.ToString(id));
			}
			catch{}
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: SaveList</para>
		/// <para>Input: List of KhachHangEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void SaveList(List<KhachHangEntity>list){
			foreach(KhachHangEntity o in list){
				try{
					this.Save(o);
				}
				catch{
				}
			}
		}
		#endregion

		#region Update functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: CreateUpdateCommand</para>
		/// <para>Input: KhachHangEntity</para>
		/// <para>Output: </para>
		///</summary>
		protected IDbCommand CreateUpdateCommand(KhachHangEntity o){
			string strSQL="UPDATE  [KhachHang] SET [KhachHang].[MaKhachHang]=@MaKhachHang,[KhachHang].[TenKhachHang]=@TenKhachHang,[KhachHang].[NgaySinh]=@NgaySinh,[KhachHang].[GioiTinh]=@GioiTinh,[KhachHang].[DiaChi]=@DiaChi,[KhachHang].[QuanHuyen_ID]=@QuanHuyen_ID,[KhachHang].[TinhThanh_ID]=@TinhThanh_ID,[KhachHang].[DiDong]=@DiDong,[KhachHang].[CoDinh]=@CoDinh,[KhachHang].[PhuHuynh]=@PhuHuynh,[KhachHang].[ThanhPhan_ID]=@ThanhPhan_ID,[KhachHang].[TruongHoc]=@TruongHoc,[KhachHang].[CaHoc_ID]=@CaHoc_ID,[KhachHang].[GioHoc]=@GioHoc,[KhachHang].[Email]=@Email,[KhachHang].[DanhGia]=@DanhGia,[KhachHang].[GhiChu]=@GhiChu,[KhachHang].[SinhVien_ID]=@SinhVien_ID,[KhachHang].[NganhHoc_ID]=@NganhHoc_ID,[KhachHang].[TrangThai_ID]=@TrangThai_ID,[KhachHang].[NguonTin_ID]=@NguonTin_ID,[KhachHang].[NgayNhap]=@NgayNhap,[KhachHang].[NgayCapNhat]=@NgayCapNhat,[KhachHang].[User_ID]=@User_ID,[KhachHang].[KetThuc]=@KetThuc,[KhachHang].[NgayKetThuc]=@NgayKetThuc WHERE [KhachHang].[KhachHang_ID]=@KhachHang_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullKhachHang_ID)
				this.CreateCommandParameter(cmd,"@KhachHang_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@KhachHang_ID",o.KhachHang_ID);

			if(o.IsNullMaKhachHang)
				this.CreateCommandParameter(cmd,"@MaKhachHang",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@MaKhachHang",o.MaKhachHang);

			if(o.IsNullTenKhachHang)
				this.CreateCommandParameter(cmd,"@TenKhachHang",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TenKhachHang",o.TenKhachHang);

			if(o.IsNullNgaySinh)
				this.CreateCommandParameter(cmd,"@NgaySinh",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NgaySinh",o.NgaySinh);

			if(o.IsNullGioiTinh)
				this.CreateCommandParameter(cmd,"@GioiTinh",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GioiTinh",o.GioiTinh);

			if(o.IsNullDiaChi)
				this.CreateCommandParameter(cmd,"@DiaChi",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DiaChi",o.DiaChi);

			if(o.IsNullQuanHuyen_ID)
				this.CreateCommandParameter(cmd,"@QuanHuyen_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@QuanHuyen_ID",o.QuanHuyen_ID);

			if(o.IsNullTinhThanh_ID)
				this.CreateCommandParameter(cmd,"@TinhThanh_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TinhThanh_ID",o.TinhThanh_ID);

			if(o.IsNullDiDong)
				this.CreateCommandParameter(cmd,"@DiDong",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DiDong",o.DiDong);

			if(o.IsNullCoDinh)
				this.CreateCommandParameter(cmd,"@CoDinh",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@CoDinh",o.CoDinh);

			if(o.IsNullPhuHuynh)
				this.CreateCommandParameter(cmd,"@PhuHuynh",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@PhuHuynh",o.PhuHuynh);

			if(o.IsNullThanhPhan_ID)
				this.CreateCommandParameter(cmd,"@ThanhPhan_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@ThanhPhan_ID",o.ThanhPhan_ID);

			if(o.IsNullTruongHoc)
				this.CreateCommandParameter(cmd,"@TruongHoc",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TruongHoc",o.TruongHoc);

			if(o.IsNullCaHoc_ID)
				this.CreateCommandParameter(cmd,"@CaHoc_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@CaHoc_ID",o.CaHoc_ID);

			if(o.IsNullGioHoc)
				this.CreateCommandParameter(cmd,"@GioHoc",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GioHoc",o.GioHoc);

			if(o.IsNullEmail)
				this.CreateCommandParameter(cmd,"@Email",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@Email",o.Email);

			if(o.IsNullDanhGia)
				this.CreateCommandParameter(cmd,"@DanhGia",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@DanhGia",o.DanhGia);

			if(o.IsNullGhiChu)
				this.CreateCommandParameter(cmd,"@GhiChu",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@GhiChu",o.GhiChu);

			if(o.IsNullSinhVien_ID)
				this.CreateCommandParameter(cmd,"@SinhVien_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@SinhVien_ID",o.SinhVien_ID);

			if(o.IsNullNganhHoc_ID)
				this.CreateCommandParameter(cmd,"@NganhHoc_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NganhHoc_ID",o.NganhHoc_ID);

			if(o.IsNullTrangThai_ID)
				this.CreateCommandParameter(cmd,"@TrangThai_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@TrangThai_ID",o.TrangThai_ID);

			if(o.IsNullNguonTin_ID)
				this.CreateCommandParameter(cmd,"@NguonTin_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NguonTin_ID",o.NguonTin_ID);

			if(o.IsNullNgayNhap)
				this.CreateCommandParameter(cmd,"@NgayNhap",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NgayNhap",o.NgayNhap);

			if(o.IsNullNgayCapNhat)
				this.CreateCommandParameter(cmd,"@NgayCapNhat",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NgayCapNhat",o.NgayCapNhat);

			if(o.IsNullUser_ID)
				this.CreateCommandParameter(cmd,"@User_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@User_ID",o.User_ID);

			if(o.IsNullKetThuc)
				this.CreateCommandParameter(cmd,"@KetThuc",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@KetThuc",o.KetThuc);

			if(o.IsNullNgayKetThuc)
				this.CreateCommandParameter(cmd,"@NgayKetThuc",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@NgayKetThuc",o.NgayKetThuc);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: CreateUpdateFieldCommand</para>
		/// <para>Input: ColumnName,ColumnValue,KhachHang_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateUpdateFieldCommand(string ColumnName,object Value,int KhachHang_ID){
			string strSQL="UPDATE  [KhachHang] SET [KhachHang].["+ColumnName+"]=@ColumnName WHERE [KhachHang].[KhachHang_ID]=@KhachHang_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@KhachHang_ID",KhachHang_ID);



			this.CreateCommandParameter(cmd,"@ColumnName",Value);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: Update</para>
		/// <para>Input: KhachHangEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Update(KhachHangEntity o){
			IDbCommand cmd=this.CreateUpdateCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateList</para>
		/// <para>Input: List of KhachHangEntity</para>
		/// <para>Output: </para>
		///</summary>
		public void UpdateList(List<KhachHangEntity>list){
			foreach(KhachHangEntity o in list){
				try{
					this.Update(o);
				}
				catch{
				}
			}
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateMaKhachHang</para>
		/// <para>Input: NewMaKhachHang,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateMaKhachHang(string NewMaKhachHang,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("MaKhachHang",NewMaKhachHang,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateTenKhachHang</para>
		/// <para>Input: NewTenKhachHang,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateTenKhachHang(string NewTenKhachHang,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("TenKhachHang",NewTenKhachHang,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateNgaySinh</para>
		/// <para>Input: NewNgaySinh,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateNgaySinh(DateTime NewNgaySinh,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("NgaySinh",NewNgaySinh,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateGioiTinh</para>
		/// <para>Input: NewGioiTinh,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateGioiTinh(bool NewGioiTinh,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("GioiTinh",NewGioiTinh,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateDiaChi</para>
		/// <para>Input: NewDiaChi,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateDiaChi(string NewDiaChi,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("DiaChi",NewDiaChi,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateQuanHuyen_ID</para>
		/// <para>Input: NewQuanHuyen_ID,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateQuanHuyen_ID(int NewQuanHuyen_ID,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("QuanHuyen_ID",NewQuanHuyen_ID,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateTinhThanh_ID</para>
		/// <para>Input: NewTinhThanh_ID,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateTinhThanh_ID(int NewTinhThanh_ID,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("TinhThanh_ID",NewTinhThanh_ID,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateDiDong</para>
		/// <para>Input: NewDiDong,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateDiDong(string NewDiDong,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("DiDong",NewDiDong,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateCoDinh</para>
		/// <para>Input: NewCoDinh,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateCoDinh(string NewCoDinh,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("CoDinh",NewCoDinh,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdatePhuHuynh</para>
		/// <para>Input: NewPhuHuynh,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdatePhuHuynh(string NewPhuHuynh,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("PhuHuynh",NewPhuHuynh,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateThanhPhan_ID</para>
		/// <para>Input: NewThanhPhan_ID,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateThanhPhan_ID(int NewThanhPhan_ID,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("ThanhPhan_ID",NewThanhPhan_ID,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateTruongHoc</para>
		/// <para>Input: NewTruongHoc,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateTruongHoc(string NewTruongHoc,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("TruongHoc",NewTruongHoc,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateCaHoc_ID</para>
		/// <para>Input: NewCaHoc_ID,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateCaHoc_ID(int NewCaHoc_ID,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("CaHoc_ID",NewCaHoc_ID,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateGioHoc</para>
		/// <para>Input: NewGioHoc,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateGioHoc(string NewGioHoc,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("GioHoc",NewGioHoc,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateEmail</para>
		/// <para>Input: NewEmail,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateEmail(string NewEmail,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("Email",NewEmail,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateDanhGia</para>
		/// <para>Input: NewDanhGia,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateDanhGia(string NewDanhGia,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("DanhGia",NewDanhGia,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateGhiChu</para>
		/// <para>Input: NewGhiChu,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateGhiChu(string NewGhiChu,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("GhiChu",NewGhiChu,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateSinhVien_ID</para>
		/// <para>Input: NewSinhVien_ID,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateSinhVien_ID(int NewSinhVien_ID,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("SinhVien_ID",NewSinhVien_ID,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateNganhHoc_ID</para>
		/// <para>Input: NewNganhHoc_ID,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateNganhHoc_ID(int NewNganhHoc_ID,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("NganhHoc_ID",NewNganhHoc_ID,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateTrangThai_ID</para>
		/// <para>Input: NewTrangThai_ID,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateTrangThai_ID(int NewTrangThai_ID,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("TrangThai_ID",NewTrangThai_ID,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateNguonTin_ID</para>
		/// <para>Input: NewNguonTin_ID,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateNguonTin_ID(int NewNguonTin_ID,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("NguonTin_ID",NewNguonTin_ID,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateNgayNhap</para>
		/// <para>Input: NewNgayNhap,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateNgayNhap(DateTime NewNgayNhap,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("NgayNhap",NewNgayNhap,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateNgayCapNhat</para>
		/// <para>Input: NewNgayCapNhat,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateNgayCapNhat(DateTime NewNgayCapNhat,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("NgayCapNhat",NewNgayCapNhat,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateUser_ID</para>
		/// <para>Input: NewUser_ID,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateUser_ID(int NewUser_ID,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("User_ID",NewUser_ID,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateKetThuc</para>
		/// <para>Input: NewKetThuc,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateKetThuc(bool NewKetThuc,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("KetThuc",NewKetThuc,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: UpdateNgayKetThuc</para>
		/// <para>Input: NewNgayKetThuc,KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool UpdateNgayKetThuc(DateTime NewNgayKetThuc,int KhachHang_ID){
			IDbCommand cmd=this.CreateUpdateFieldCommand("NgayKetThuc",NewNgayKetThuc,KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Delete functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: DeleteAllCommand</para>
		/// <para>Input: </para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteAllCommand(){
			string strSQL="DELETE   FROM [KhachHang]  ";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: DeleteCommand</para>
		/// <para>Input: KhachHangEntity</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteCommand(KhachHangEntity o){
			string strSQL="DELETE   FROM [KhachHang]   WHERE [KhachHang].[KhachHang_ID]=@KhachHang_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			if(o.IsNullKhachHang_ID)
				this.CreateCommandParameter(cmd,"@KhachHang_ID",System.DBNull.Value);
			else
				this.CreateCommandParameter(cmd,"@KhachHang_ID",o.KhachHang_ID);


			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: DeleteAll</para>
		/// <para>Input: </para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteAll(){
			IDbCommand cmd=this.CreateDeleteAllCommand();
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: CreateDeleteByPrimaryKeyCommand</para>
		/// <para>Input: KhachHang_ID</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByPrimaryKeyCommand(int KhachHang_ID){
			string strSQL="DELETE   FROM [KhachHang]   WHERE [KhachHang].[KhachHang_ID]=@KhachHang_ID";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@KhachHang_ID",KhachHang_ID);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: CreateDeleteByKeyCommand</para>
		/// <para>Input: ColumnName , ColumnValue</para>
		/// <para>Output: IDbCommand</para>
		///</summary>
		protected IDbCommand CreateDeleteByKeyCommand(string ColumnName,object Value){
			string strSQL="DELETE   FROM [KhachHang]   WHERE [KhachHang].["+ColumnName+"]=@ColumnName";
			IDbCommand cmd=this.CreateCommand(strSQL);
			cmd.CommandType=CommandType.Text;
			this.CreateCommandParameter(cmd,"@ColumnName",Value);



			return cmd;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: Delete</para>
		/// <para>Input: KhachHangEntity</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool Delete(KhachHangEntity o){
			IDbCommand cmd=this.CreateDeleteCommand(o);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: DeleteByID</para>
		/// <para>Input: KhachHang_ID</para>
		/// <para>Output: return true if succeeded else return false</para>
		///</summary>
		public bool DeleteByID(int KhachHang_ID){
			IDbCommand cmd=this.CreateDeleteByPrimaryKeyCommand(KhachHang_ID);
			bool result=this.ExcuteNoneQuery(cmd);
			cmd.Dispose();
			return result;
		}
		#endregion

		#region Select join to CaHocNganhHocNguonTinQuanHuyenSinhVienThanhPhanTinhThanhTrangThaiKHUsers functions
		#endregion

		#region Select join to CaHoc functions
		#endregion

		#region Select join to NganhHoc functions
		#endregion

		#region Select join to NguonTin functions
		#endregion

		#region Select join to QuanHuyen functions
		#endregion

		#region Select join to SinhVien functions
		#endregion

		#region Select join to ThanhPhan functions
		#endregion

		#region Select join to TinhThanh functions
		#endregion

		#region Select join to TrangThaiKH functions
		#endregion

		#region Select join to Users functions
		#endregion

		#region Select,delete by KhachHang_ID functions
		#endregion

		#region Select,delete by QuanHuyen_ID functions
		#endregion

		#region Select,delete by TinhThanh_ID functions
		#endregion

		#region Select,delete by ThanhPhan_ID functions
		#endregion

		#region Select,delete by CaHoc_ID functions
		#endregion

		#region Select,delete by SinhVien_ID functions
		#endregion

		#region Select,delete by NganhHoc_ID functions
		#endregion

		#region Select,delete by TrangThai_ID functions
		#endregion

		#region Select,delete by NguonTin_ID functions
		#endregion

		#region Select,delete by User_ID functions
		#endregion

		#region MapObject functions
		///<summary>
		/// <para>Author: Auto generated by CSharp Code Generator v2.0</para>
		/// <para>Date:27/10/2011 56:03:12</para>
		/// <para>Name: MapObject</para>
		/// <para>Input: IDataReader</para>
		/// <para>Output: KhachHangEntity</para>
		///</summary>
		protected override KhachHangEntity MapObject(IDataReader r){
			KhachHangEntity entity = new KhachHangEntity();
			try{
				if(r.FieldCount>0){
					try
					{
						int ordinal = r.GetOrdinal("KhachHang_ID");
						if (!r.IsDBNull(ordinal)) entity.KhachHang_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("MaKhachHang");
						if (!r.IsDBNull(ordinal)) entity.MaKhachHang = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("TenKhachHang");
						if (!r.IsDBNull(ordinal)) entity.TenKhachHang = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("NgaySinh");
						if (!r.IsDBNull(ordinal)) entity.NgaySinh = ((DateTime)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("GioiTinh");
						if (!r.IsDBNull(ordinal)) entity.GioiTinh = ((bool)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("DiaChi");
						if (!r.IsDBNull(ordinal)) entity.DiaChi = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("QuanHuyen_ID");
						if (!r.IsDBNull(ordinal)) entity.QuanHuyen_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("TinhThanh_ID");
						if (!r.IsDBNull(ordinal)) entity.TinhThanh_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("DiDong");
						if (!r.IsDBNull(ordinal)) entity.DiDong = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("CoDinh");
						if (!r.IsDBNull(ordinal)) entity.CoDinh = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("PhuHuynh");
						if (!r.IsDBNull(ordinal)) entity.PhuHuynh = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("ThanhPhan_ID");
						if (!r.IsDBNull(ordinal)) entity.ThanhPhan_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("TruongHoc");
						if (!r.IsDBNull(ordinal)) entity.TruongHoc = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("CaHoc_ID");
						if (!r.IsDBNull(ordinal)) entity.CaHoc_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("GioHoc");
						if (!r.IsDBNull(ordinal)) entity.GioHoc = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("Email");
						if (!r.IsDBNull(ordinal)) entity.Email = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("DanhGia");
						if (!r.IsDBNull(ordinal)) entity.DanhGia = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("GhiChu");
						if (!r.IsDBNull(ordinal)) entity.GhiChu = ((string)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("SinhVien_ID");
						if (!r.IsDBNull(ordinal)) entity.SinhVien_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("NganhHoc_ID");
						if (!r.IsDBNull(ordinal)) entity.NganhHoc_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("TrangThai_ID");
						if (!r.IsDBNull(ordinal)) entity.TrangThai_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("NguonTin_ID");
						if (!r.IsDBNull(ordinal)) entity.NguonTin_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("NgayNhap");
						if (!r.IsDBNull(ordinal)) entity.NgayNhap = ((DateTime)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("NgayCapNhat");
						if (!r.IsDBNull(ordinal)) entity.NgayCapNhat = ((DateTime)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("User_ID");
						if (!r.IsDBNull(ordinal)) entity.User_ID = ((int)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("KetThuc");
						if (!r.IsDBNull(ordinal)) entity.KetThuc = ((bool)(r.GetValue(ordinal)));
					}
					catch{}
					try
					{
						int ordinal = r.GetOrdinal("NgayKetThuc");
						if (!r.IsDBNull(ordinal)) entity.NgayKetThuc = ((DateTime)(r.GetValue(ordinal)));
					}
					catch{}
					return entity;
				}
			}catch{}
			return null;
		}
		#endregion
	}
	/*****************************************************************************************************/
	/**********************************END KhachHangDAOBase*****************************************/
	/*****************************************************************************************************/
}

